/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package controller;

import entities.Report;
import java.util.List;
import javax.persistence.EntityManager;
import javax.persistence.Persistence;
import javax.persistence.Query;

/**
 *
 * @author QUY-THI
 */
public class ReportsOfUser {

    public List<Report> reportsOfUser(int userid) {
        EntityManager em = Persistence.createEntityManagerFactory("E-AdministrationPU").createEntityManager();
        Query q = em.createQuery("select r from Report r where r.sender.userID=:userid order by r.reportID DESC");
        q.setParameter("userid", userid);
        return (List<Report>) q.getResultList();
    }
}
